package com.dhcc.core.modules.msgcenter.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 接受者类型
 * @ClassName: MsgReceiveType 
 * @Description: TODO
 * @author: cyf
 * @date: 2018年10月16日 上午9:16:36
 */
public enum MsgReceiveType {
    ALL("全体",0),
    USER("用户",1),
    DEPT("部门",2),
    GROUP("群组",3),
    ROLE("角色",4),
    POSITION("职务",5);

    private String name;
    private int code;

    MsgReceiveType(String name, int code) {
        this.name = name;
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public static String valueOf(Integer value) {
        if (value == null) {
            return "";
        } else {
            for (MsgReceiveType rt : MsgReceiveType.values()) {
                if (rt.getCode() == value) {
                    return rt.getName();
                }
            }
            return "";
        }
    }

    public static Map<Integer,String> map() {
        Map<Integer,String> map = new HashMap<>();
        for (MsgReceiveType pt : MsgReceiveType.values()) {
            map.put(pt.getCode(),pt.getName());
        }
        return map;
    }
}
